﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using MathExpressionSolver.App_Code;

namespace MathExpressionSolver
{
    public partial class MathCompare : System.Web.UI.Page
    {
        //*************************************************
        //                  Page Load
        //*************************************************
        #region Page Load
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        #endregion
        //*************************************************



        //*************************************************
        //                   Buttons
        //*************************************************
        #region Buttons
        protected void btnEquals_Click(object sender, EventArgs e)
        {
            try
            {
                lblResult.ForeColor = System.Drawing.Color.Black;

                //ToDo: Bug when multiplying or dividing a number by a negative value.
                lblResult.Text = string.Format("{0}", Math_Functions.EvalCompare(txtExpression.Text));
            }
            catch (Exception ex)
            {
                lblResult.ForeColor = System.Drawing.Color.Red;

                lblResult.Text = string.Format("Error: {0}", ex.Message);
            }
        }
        #endregion
        //*************************************************
    }
}